	function initConsole(){
		// 初始化左侧菜单
		$(".lm_menu a").each(function(index){
			$(this).click(function(){
				clickLeftMenu($(this).attr('id'));
			});
		});
		
		// 初始化全局事件
		$(document).click(function(){
			$(".options_area").hide();
		});
		
		$(".options_area").click(function(e){
			e.stopPropagation();
		});
	}

	function clickLeftMenu(menuId){
		var method = menuId.substring(0, menuId.lastIndexOf("_"));
		var id = menuId.substring(menuId.lastIndexOf("_")+1);
		try{
			eval(method+"('"+id+"')");	
		}catch(e){
			alert("未找到对应的方法");
		}
	}
	
	function getGradeInfo(gradeId){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("年级信息");
		$("#gradeinfoarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_gradeinfo").show();
	}
	
	function newGrade(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("新增年级");
		$("#newgradearea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_newgrade").show();
	}
	
	function gradeCancelSave(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("年级信息");
		$("#gradeinfoarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_gradeinfo").show();
	}
	
	function listTeacher(gradeId){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("年级教师");
		$("#tacherlistarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_teacher").show();
		$("#progress").show();
		$.ajax({
			type	:	'POST',
			url		:	'/teacher/json/listteacher',
			data	:	{
						"gradeId":	gradeId	
			},
			success	:	function(r){
				$("#teacherlisttable .listtable_row").remove();
				if(r.result) {
					$("#progress").hide();
					var htmlStr = '';
					$.each(r.obj, function(i, info){
						htmlStr+='<div class="listtable_row">';
						htmlStr+='	<span style="width:43px;"><input type="checkbox" name="" /></span>';
						htmlStr+='	<span><a href="javascript:getTeacher(\''+info.teacherId+'\')">'+info.teacherName+'</a></span>';
						htmlStr+='	<span>'+info.email+'</span>';
						htmlStr+='	<span>'+info.mobile+'</span>';
						htmlStr+='	<span>'+info.lastLoginDate+'</span>';
						htmlStr+='</div>';
					});
					
				}
				$("#teacherlisttable .listtable_head").after(htmlStr);
			},
			error	:	function(xhr){
				$("#progress").hide();
			}
		});
	}
	
	function getTeacher(teacherId){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("教师信息");
		$("#teacherdetailarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_teacher").show();
		$("#progress").show();
		$.ajax({
			type	:	'POST',
			url		:	'/teacher/json/getteacher',
			data	:	{
						"teacherId":	teacherId	
			},
			success	:	function(r){
				if(r.result) {
					$("#progress").hide();
					var teacher = r.obj;
					$("#teacherdetail_teacherName").text(teacher.teacherName);
					$("#teacherdetail_gender").text(teacher.gender);
				}
			},
			error	:	function(xhr){
				$("#progress").hide();
			}
		});
	}
	
	function newTeacher(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("新增教师");
		$("#newteacherarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_newteacher").show();
	}
	
	function uploadTeacher(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("上传教师");
		$("#uploadteacherarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_uploadteacher").show();
		
		$("#teacherfile").uploadify({
			'auto'		: false,
            'swf'		: '/resources/image/uploadify.swf',
            'uploader'	: '/teacher/json/uploadteacher',
            'buttonText': '选择文件',
            'width'		: 120,
            'height'	: 30,
            'multi'		: false,
            'fileTypeDesc' : 'Excel 文件',
            'fileTypeExts'	: '*.xls;*.xlsx'
        });
	}
	
	function addGradeTeacherOptions(){
		var left = $("#addGradeTeacherButton").position().left;
		var top = $("#addGradeTeacherButton").position().top;
		var height = $("#addGradeTeacherButton").height();

		$("#options_teacher_quickadd").css("left", left);
		$("#options_teacher_quickadd").css("top", top+height-2);
		$("#options_teacher_quickadd").toggle();
		
		$("#teacherQuickAddKeyword").autocomplete(){
			url	: "/teacher/json/quicksearchteacher",
			sortFunction: function(a, b, filter) {
				var f = filter.toLowerCase();
				var fl = f.length;
				var a1 = a.value.toLowerCase().substring(0, fl) == f ? '0' : '1';
				var a1 = a1 + String(a.data[0]).toLowerCase();
				var b1 = b.value.toLowerCase().substring(0, fl) == f ? '0' : '1';
				var b1 = b1 + String(b.data[0]).toLowerCase();
				if (a1 > b1) {
				    return 1;
				}
				if (a1 < b1) {
				    return -1;
				}
				return 0;
			},
			showResult: function(value, data) {
	            return '<span style="color:red">' + value + '</span>';
	        },
	        onItemSelect: function(item) {
	            var text = 'You selected <b>' + item.value + '</b>';
	            if (item.data.length) {
	                text += ' <i>' + item.data.join(', ') + '</i>';
	            }
	            $("#last_selected").html(text);
	        },
			mustMatch: true,
	        maxItemsToShow: 5,
	        selectFirst: false,
	        autoFill: false,
	        selectOnly: true,
	        remoteDataType: 'json'
		};
	}
	
	function updateTeacher(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("教师信息修改");
		$("#newteacherarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_newteacher").show();
	}
	
	function updateTeacherSubject(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("教师任课信息修改");
		$("#teachersubjectarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_newteacher").show();
	}
	
	function teacherCancelSave(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("教师列表");
		$("#tacherlistarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_teacher").show();
	}
	
	function newClazz(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("新增班级");
		$("#newclazzarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_newclazz").show();
	}
	
	function clazzCancelSave(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("班级列表");
		$("#clazzlistarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_listclazz").show();
	}
	
	function listClazz(gradeId){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("班级列表");
		$("#clazzlistarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_listclazz").show();
		$("#progress").show();
		$.ajax({
			type	:	'POST',
			url		:	'/teacher/json/listclazz',
			data	:	{
						"gradeId":	gradeId	
			},
			success	:	function(r){
				$("#clazzlisttable .listtable_row").remove();
				if(r.result) {
					$("#progress").hide();
					var htmlStr = '';
					$.each(r.obj, function(i, info){
						htmlStr+='<div class="listtable_row">';
						htmlStr+='	<span style="width:43px;"><input type="checkbox" name="" /></span>';
						htmlStr+='	<span><a href="javascript:getClazz(\''+info.teacherId+'\')">'+info.clazzName+'</a></span>';
						htmlStr+='	<span>'+info.headTeacher.teacherName+'</span>';
						htmlStr+='	<span>'+0+'</span>';
						htmlStr+='</div>';
					});
					
				}
				$("#clazzlisttable .listtable_head").after(htmlStr);
			},
			error	:	function(xhr){
				$("#progress").hide();
			}
		});
	}
	
	function listExam(gradeId){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("考试管理");
		$("#examlistarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_listexam").show();
		$("#progress").show();
		$.ajax({
			type	:	'POST',
			url		:	'/teacher/json/listexam',
			data	:	{
						"gradeId":	gradeId	
			},
			success	:	function(r){
				$("#examlisttable .listtable_row").remove();
				if(r.result) {
					$("#progress").hide();
					var htmlStr = '';
					$.each(r.obj, function(i, info){
						htmlStr+='<div class="listtable_row">';
						htmlStr+='	<span style="width:43px;"><input type="checkbox" name="" /></span>';
						htmlStr+='	<span><a href="javascript:getExam(\''+info.examId+'\')">'+info.examName+'</a></span>';
						htmlStr+='	<span>'+info.status+'</span>';
						htmlStr+='	<span>'+0+'</span>';
						htmlStr+='</div>';
					});
					
				}
				$("#examlisttable .listtable_head").after(htmlStr);
			},
			error	:	function(xhr){
				$("#progress").hide();
			}
		});
	}
	
	function getExam(examId){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("考试信息");
		$("#examdetailarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_examdetail").show();
		
	}
	
	function newExam(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("新增考试");
		$("#newexamarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_newexam").show();
	}
	
	function uploadExam(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("上传成绩");
		$("#uploadexamarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_uploadexam").show();
		
		$("#examfile").uploadify({
			'auto'		: false,
            'swf'		: '/resources/image/uploadify.swf',
            'uploader'	: '/teacher/json/uploadexam',
            'buttonText': '选择文件',
            'width'		: 120,
            'height'	: 30,
            'multi'		: false,
            'fileTypeDesc' : 'Excel 文件',
            'fileTypeExts'	: '*.xls;*.xlsx'
        });
	}
	
	function getExamAnalysisOptions(){
		var left = $("#getExamAnalysisButton").position().left;
		var top = $("#getExamAnalysisButton").position().top;
		var height = $("#getExamAnalysisButton").height();

		$("#options_exam_analysis").css("left", left);
		$("#options_exam_analysis").css("top", top+height-2);
		$("#options_exam_analysis").toggle();
	}
	
	function sendExamResultOptions(){
		var left = $("#sendExamResultButton").position().left;
		var top = $("#sendExamResultButton").position().top;
		var height = $("#sendExamResultButton").height();

		$("#options_sendpoint").css("left", left);
		$("#options_sendpoint").css("top", top+height-2);
		$("#options_sendpoint").toggle();
	}
	
	function setExamConfigOptions(){
		var left = $("#setExamConfigButton").position().left;
		var top = $("#setExamConfigButton").position().top;
		var height = $("#setExamConfigButton").height();

		$("#options_exam_setting").css("left", left);
		$("#options_exam_setting").css("top", top+height-2);
		$("#options_exam_setting").toggle();
	}
	
	function examCancelSave(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("考试管理");
		$("#examlistarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_listexam").show();
	}
	
	function listClazzBlog(clazzId){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("班级日志");
		$("#bloglistarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_listexam").show();
		$("#progress").show();
		$.ajax({
			type	:	'POST',
			url		:	'/teacher/json/listclazzblog',
			data	:	{
						"clazzId":	clazzId	
			},
			success	:	function(r){
				if(r.result) {
					$("#progress").hide();
					
				}
			},
			error	:	function(xhr){
				$("#progress").hide();
			}
		});
	}
	
	function listClazzStudent(clazzId){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("班级学生");
		$("#studentlistarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_listclazzstudent").show();
		$("#progress").show();
		$.ajax({
			type	:	'POST',
			url		:	'/teacher/json/listclazzstudent',
			data	:	{
						"clazzId":	clazzId	
			},
			success	:	function(r){
				if(r.result) {
					$("#progress").hide();
					
				}
			},
			error	:	function(xhr){
				$("#progress").hide();
			}
		});
	}
	
	function newStudent(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("新增学生");
		$("#newstudentarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_newstudent").show();
	}
	
	function uploadStudent(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("上传学生");
		$("#uploadteacherarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_uploadstudent").show();
		
		$("#studentfile").uploadify({
			'auto'		: false,
            'swf'		: '/resources/image/uploadify.swf',
            'uploader'	: '/teacher/json/uploadteacher',
            'buttonText': '选择文件',
            'width'		: 120,
            'height'	: 30,
            'multi'		: false,
            'fileTypeDesc' : 'Excel 文件',
            'fileTypeExts'	: '*.xls;*.xlsx'
        });
	}
	
	function studentCancelSave(){
		$(".panelarea").each(function(){
			$(this).hide();
		});
		$("#panel_nav").text("学生列表");
		$("#studentlistarea").show();
		$("#operationarea .operation").each(function(){
			$(this).hide();
		});
		$("#operation_listclazzstudent").show();
	}
